package com.herui.iot.ui;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.herui.sdyu_lib.base.BaseFragment;
import com.herui.sdyu_lib.utils.LogUtils;
import com.herui.sport_care.R;

import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * Created by amanda.shan on 2022/5/22.
 */
public abstract class BaseSportFragment extends BaseFragment {

    protected Unbinder unbinder;
    View rootView;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle
            savedInstanceState) {
        rootView = super.onCreateView(inflater, container, savedInstanceState);
        unbinder = ButterKnife.bind(this, rootView);

        View back = rootView.findViewById(R.id.view_back);
        if (back != null) {
            View view = back.findViewById(R.id.imgv_back);
            view.setOnClickListener(v -> {
                baseActivity.onBackPressed();
                LogUtils.i("back");
            });
        }

        return rootView;
    }

    protected void setTitle( String title) {
        View back = rootView.findViewById(R.id.view_back);
        if (back != null){
            TextView textView = back.findViewById(R.id.tv_title);
            textView.setText(title);
        }
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }
}
